1. Field of the Invention
The present invention relates generally to computer graphics systems and, more particularly, to methods and apparatus for compositing three-dimensional images in a computer graphics pipeline.
2. Related Art
Computer graphics systems are commonly used for displaying two- and three-dimensional graphics representations of objects on a two-dimensional display screen. Current computer graphics systems provide highly detailed representations and are used in a variety of applications.
In a typical computer graphics system, an object to be represented on the display screen is broken down into graphics primitives. Primitives are basic components of a graphics display and may include, for example, points, lines, quadrilaterals, triangle strips and polygons. Typically, a hardware/software scheme is implemented to render, or draw, the graphics primitives that represent a view of one or more objects on the display screen.
Generally, the primitives of a three-dimensional object to be rendered are defined by a graphics application residing on a host computer in terms of primitive data. For example, when the primitive is a triangle, the host computer may define the primitive in terms of the X, Y, Z and W coordinates of its vertices, as well as the red, green, blue and alpha (R, G, B and A) color values of each vertex. Additional primitive data such as texture mapping data may be used in some applications. Rendering hardware interpolates the primitive data to dtermine the display screen pixels that represent each primitive, and the R, G and B color values for each pixel.
The basic components of a computer graphics system typically include a computer graphics library that contains software routines that control graphics hardware in response to function calls issued by the graphics application. The graphics hardware may include, for example, a geometry accelerator, a rasterizer, a frame buffer controller and a frame buffer. The system may also include other hardware such as texture mapping hardware. The geometry accelerator receives from the graphics application primitive data that defines the primitives that make up the view of the object to be displayed, referred to herein as the “model view”. The geometry accelerator performs transformations on the primitive data and performs such functions as lighting, clipping and plane equation calculations for each primitive. The output of the geometry accelerator, referred to as rendering data, is used by the rasterizer and the texture mapping hardware to generate final screen coordinate (X,Y) and color data (R,G,B,A) for each pixel, collectively referred to herein as pixel data.
Texture mapping permits objects to be displayed with improved surface detail. Texture mapping involves mapping a source image, refered to as a texture, onto the surface of a three-dimensional object. Thereafter, the textured three-dimensional object is projected on the two-dimensional display screen to display the resulting image. Texture mapping involves applying one or more point elements (texels) of a texture to each point element (pixel) of the object image. The pixel data from the rasterizer and the pixel data from the texture mapping hardware are combined and stored in the frame buffer for subsequent display on the display screen.
The graphics library typically provides an application program interface (API) to enable graphics applications executing on the host computer to control efficiently the graphics hardware. Commonly, the OpenGL® standard is utilized to provide a graphics library API to the graphics system. (OpenGL is a registered trademark of Silicon Graphics, Inc.). The OpenGL standard provides a complete library of low-level graphics manipulation commands for describing models of three-dimensional objects (the “GL” of OpenGL refers to “graphics library”). This standard was originally based on the proprietary standards of Silicon Graphics, Inc., and was later transformed into an open standard now used in high-end graphics workstations and, more recently, in high-end personal computers. The OpenGL standard is described in the “OpenGL Programming Guide”, version 1.1 (1997), the “OpenGL Reference Manual”, version 1.1 (1997), and the “OpenGL Specification”, version 1.1 (1997), all of which are hereby incorporated by reference in their entirety.
The OpenGL software interface provides specific commands that are used to specify objects and operations to produce interactive graphics systems. OpenGL is a streamlined, hardware-independent interface designed to be implemented on many different hardware platforms. As such, in computer systems that support OpenGL, the operating systems and graphics applications can make function calls to the computer graphics system according to the standardized API without knowledge of the underlying hardware configuration.
Various techniques have been employed to improve the performance of graphics systems. Due to the large number of at least partially independent operations that are performed to render a graphics image, proposals have been made to use some form of parallel architecture for graphics systems. One common approach to achieving parallelism in computer graphics processing is a technique known as pipelining. In a pipelined architecture, individual processing stages are, in effect, connected in series in an assembly-line configuration. One processing stage performs a first set of operations on one set of data and passes that data along to another processing stage. This next processing stage performs a second set of operations while at the same time the first processing stage performs again the first set of operations on another set of data.
The graphics library is typically logically divided into software routines that are accessible through the API and perform various operations, and device-specific software routines that control specific graphics hardware components. Together, the device-specific software routines and the graphics hardware components define what is commonly referred to as a graphics rendering pipeline.
There are two paths through a rendering pipeline, one for primitive data and one for pixel data. The former path processes three-dimensional (3D) primitive data to form a two-dimensional (2D) image for display on a 2D display screen. The latter path manipulates pixels, images and bitmaps of existing 2D images. The Cartesian coordinates of an image include X and Y coordinates corresponding to the pixel address in the horizontal and vertical dimensions of the display screen, and the Z coordinate which is orthogonal to the display screen and represents the distance from the location of the viewer, referred to as the viewpoint. The former path is referred to herein as a 3D pipeline due to the inclusion of depth information (Z coordinate data) in the primitive data. In contrast, the latter path is referred to as a 2D pipeline due to the absence of Z coordinate data from the 2D image data. This is because only the address (X,Y coordinate) and color (R,G,B,A) data is required to display a 2D image on a 2D display screen.
When rendering a scene comprised of multiple model views, the geometric pipeline processes the model views concurrently to properly form a realistic scene. The geometric pipeline renders the model views such that when multiple objects are to be rendered at the same pixel location, the pixel is rendered in the color of the object that is closest to the viewer. To make such a determination Z coordinate information is required to be included in the primitive data for each object, and the geometric pipeline must include the requisite components to perform the necessary comparison operations. For example, an OpenGL geometric pipeline includes a depth buffer to store Z coordinate data, and a depth test module to perform the requisite comparison operations.
It is often desirable to composite (combine) images that are not rendered concurrently. For example, pixel data for an image may be stored to a computer-readable file for future restoration during another session or on a graphics system different than the graphics system in which the image was created. Another example is when images from different sources are brought together on a graphics system to form a single, integrated image. These images may have been generated at some prior time using a graphics geometric pipeline or through some other known technique such as through image scanning. Unfortunately, conventional geometric pipelines cannot be used to perform such compositing operations because the separate images are defined by primitive data, not primitive data. In addition, the images are generated separately and, therefore, cannot be processed concurrently through the geometric pipeline. Nor can conventional imaging pipelines be used. Existing imaging pipelines are not designed to process depth information since Z coordinate data is not available in 2D pixel data which the imaging pipeline is designed to process. Therefore, separately-generated 3D images cannot be composited using conventional rendering pipelines. Accordingly, it is desirable to provide a method and apparatus to composite one or more separately generated 3D images using a graphics rendering pipeline regardless of the location, relative timing and method utilized to generate the images.